#ifndef VM_FRAME_H
#define VM_FRAME_H
#include "stdbool.h"
#include "stdint.h"
#include "threads/synch.h"

struct lock frame_lock;

int frame_cnt;
uint32_t frame_kpage_base;
struct frame *frames;

struct frame
{
	//upage value
	void *upage;
	//thread *
	struct thread *t;
};

/*
 * Initialize frame
 */
void frame_init(void);

/*
 *  allocate frame
 */
void* frame_allocate(bool);

/*
 *  deallocate frame
 */
void frame_deallocate(void*);

/*
 * when exit,
 * look up whole frame table, clean up frames
 */
void frame_clear(void);

/*
 * get frame, eviction
 */
struct frame* frame_select(void);

/*
 * insert page to frame
 */
bool frame_insert_page(void *, void *, bool);

/*
 * from palloc, set cnt, base
 */
void frame_set_init_variable(int,uint32_t);

// for debug
int get_frame_count(void);
uint32_t get_kpage_base(void);

#endif
